/**
 * @Project Name:authentication-server
 * @Package Name:cn.hoofungson.blog.authentication.server.config
 * @Since JDK 1.8
 */

package cn.hoofungson.blog.authentication.server.config.oauth2;

import cn.hoofungson.blog.authentication.server.constant.JwtConstants;
import cn.hoofungson.blog.authentication.server.enhancer.JwtTokenEnhancer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

/**
 * @Description: JwtConfig
 * @Author 胡松 hoofungson@163.com
 * @Date 2020-01-16 17:44
 * @Version V1.0
 */
@Configuration
public class JwtConfig {

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter() {
        JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
        accessTokenConverter.setSigningKey(JwtConstants.DEFAULT_SIGNING_KEY);//配置JWT使用的秘钥
        return accessTokenConverter;
    }

    @Bean
    public TokenEnhancer tokenEnhancer() {
        return new JwtTokenEnhancer();
    }
}
